package com.eventx;


import com.eventx.bus.channel.ChannelProvider;
import com.eventx.bus.config.EventConfigItem;
import com.eventx.bus.event.EventHandler;
import com.eventx.config.RedisEventConfigManager;

/**
 * @author: anrror
 **/
public class EventBus {

    public static void publish(String eventName, Object object){
        EventConfigItem eventConfigItem = RedisEventConfigManager.get(eventName);
        ChannelProvider channelProvider = eventConfigItem.getChannelProvider();
        channelProvider.sendMessage(eventName,object);
    }

    public static void register(EventHandler handler){
        EventConfigItem eventConfigItem = RedisEventConfigManager.get(handler.getEventName());
        ChannelProvider channelProvider = eventConfigItem.getChannelProvider();
        channelProvider.subscriber(handler);
    }

}
